<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/9/22
 * Time: 17:26
 */
namespace app\share\controller;

use app\share\model\TurnTable;

class LuckDraw
{
    public function __construct()
    {
        $this->luck_draw = new TurnTable();
    }
    /**
     * 抽奖活动
     * 注: 权重为0的奖品,永远抽不中,奖品中不能权重都为0;
     * @return   string   中奖奖品id
     */
    public function luckDraw()
    {
        // 奖品数组
        $proArr = array(
            // id => 奖品等级(奖品id)， name => 奖品名称, v => 奖品权重
            array('id'=>1,'name'=>'特等奖','v'=>1),
            array('id'=>2,'name'=>'一等奖','v'=>1),
            array('id'=>3,'name'=>'二等奖','v'=>1),
            array('id'=>4,'name'=>'谢谢参与','v'=>1),
        );
        return $this->luck_draw->getRand($proArr);
    }

}